package com.clf.data.redis.core.json;

import com.alibaba.fastjson.JSON;
import org.springframework.data.redis.serializer.SerializationException;

/**
 * fastjson解析器，主要解析带有  Class type指定类型
 *
 * @author <a href="mailto:zhudelie@zuozh.com">zhudelie</a>
 * @since JDK 1.6
 * create on 2017年3月31日
 * Copyright 2017 ZZJR All Rights Reserved.
 */
public class FastJsonSerializer<T> extends FastJsonSerializerAbstractor<T> {
    Class<T> type;

    public FastJsonSerializer(Class<T> type) {
        this(type, true);
    }

    public FastJsonSerializer(Class<T> type, boolean autoRemove) {
        super(autoRemove);
        this.type = type;
    }

    @Override
    protected T deserialize0(byte[] bytes) throws SerializationException {
        return JSON.parseObject(bytes, type);
    }

}
